<template>
  <div>
    <!-- 订阅提醒-->
    <div class="card_sub_wrapper">
      <!-- 订阅方式组件 -->
      <div>
        <SubscribeWay @changeStatus="sebWayDialog"></SubscribeWay>
      </div>
      <!-- 订阅提醒信息展示组件 -->
      <SubMsgList />
    </div>
    <!-- 股池列表  -->
    <StockList />
    <!-- 个股订阅列表 -->
    <div>
      <Subscribe :isShow="isShow" @changeStatus="hideDialog"> </Subscribe>
    </div>
  </div>
</template>
<script>
import StockList from '@/components/StockList';
import SubscribeWay from '@/components/common/SubscribeWay';
import SubMsgList from '@/components/common/SubMsgList';
import { GET_SUB } from '@/apis';

export default {
  props: {
    reload: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      isShow: false,
      allStocks: [],
    };
  },
  computed: {
    //重新加载
    reload() {
      return this.$store.state.baseInfo.pushType;
    },
  },
  components: {
    SubscribeWay,
    SubMsgList,
    StockList,
  },
  watch: {
    reload: {
      handler() {
        this.getAllStocks();
        this.$store.commit('setBaseInfo', { reload: '' });
      },
    },
  },
  mounted() {
    this.getAllStocks();
  },
  methods: {
    hideDialog(arr) {
      this.isShow = arr.showStatus;
    },
    async getAllStocks() {
      const params = {};
      params.type = 3;
      params.version = 2;
      params.data = true;
      const res = await GET_SUB(params);
      if (Number(res.code) === 0 && res.data) {
        this.allStocks = res.data;
      }
    },
    sebWayDialog() {
      if (!this.allStocks.length && !this.$store.state.baseInfo.pushType) {
        this.$toast('请先订阅一个股池');
        return;
      }
      this.isShow = !this.isShow;
      this.$store.commit('setBaseInfo', { isShowSubWay: !this.$store.state.baseInfo.isShowSubWay });
    },
  },
};
</script>
<style lang="less" scoped>
.card_sub_wrapper {
  position: relative;
  width: 7.42rem;
  font-size: 0.28rem;
  margin: 0 auto;
  background-color: #fff;
  padding-bottom: 10%;
}
[theme-mode='black'] .card_sub_wrapper {
  position: relative;
  width: 7.42rem;
  font-size: 0.28rem;
  margin: 0 auto;
  background-color: #1a1a1a;
  padding-bottom: 10%;
}
</style>
